package com.java.oplog.controller;

import com.alibaba.fastjson.JSONObject;
import com.java.oplog.anno.Log;
import com.java.oplog.domain.OpLog;
//import com.java.oplog.repository.OpLogRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;


/**
 * @author cf
 */
@Slf4j
@RestController
public class TestController {

//    @Resource
//    OpLogRepository opLogRepository;

    @PostMapping("/test")
//    @OpLogAnnotation(name = "测试")
    @Log(title = "测试")
    public String test(@RequestParam("name") String name) {
        return name;
    }

    @GetMapping("/test1")
//    @OpLogAnnotation(name = "测试")
    @Log(title = "测试")
    public JSONObject test1(@RequestBody JSONObject data) {
        return data;
    }

    @GetMapping("/test2")
//    @OpLogAnnotation(name = "测试")
    @Log(title = "测试")
    public JSONObject test2(@RequestBody JSONObject data) {
        int x = 1 / 0;
        return data;
    }

//    @GetMapping("/test3")
//    public JSONObject test3() {
//        //分页参数
//        Pageable pageable = PageRequest.of(0, 10);
//        OpLog opLog = new OpLog();
//        Example<OpLog> example = Example.of(opLog);
//        Page<OpLog> all = opLogRepository.findAll(example, pageable);
//        JSONObject data = new JSONObject();
//        data.put("data",all);
//        return data;
//    }


}
